
from time import sleep
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium import webdriver
# 导入 Service 类（关键）
from selenium.webdriver.chrome.service import Service


#实例化对象：

service = Service(executable_path="E:\\python\\python38\\chromedriver.exe")
driver = webdriver.Chrome(service=service)
url = r"C:\Users\alg\PycharmProjects\UI自动化\注册实例.html"
driver.get(url)
action = ActionChains(driver)
driver.maximize_window()
sleep(5)


#填写主页面注册信息
driver.find_element(By.CSS_SELECTOR,"#user").send_keys("admin")
driver.find_element(By.CSS_SELECTOR,"#password").send_keys("123456")
driver.find_element(By.CSS_SELECTOR,"#tel").send_keys("130888888888")
driver.find_element(By.CSS_SELECTOR,"#email").send_keys("123@qq.com")


#通过链接跳转到a页面进行注册
driver.find_element(By.PARTIAL_LINK_TEXT,"A网页").click()
driver.find_element(By.ID,"#userA").send_keys("111111111")
driver.find_element(By.ID,"#passwordA").send_keys("123456")
driver.find_element(By.ID,"#telA").send_keys("130888888888")
driver.find_element(By.ID,"#emailA").send_keys("123@qq.com")

sleep(2)
